// stores/counterStore.js
import { defineStore } from 'pinia';
import { getMenus } from '@/store/mock/menus.js'
import { collectPermissionCodes } from '@/utils/auth.js'
export const menuStore = defineStore({
  id: 'menu',
  state: () => ({
    menus: [],
    collapse: false
  }),
  actions: {
    getMenusList() {
      // console.log('getMenusList')
      // this.menus = await getMenus();
      // console.log('action->this.menus', this.menus)
      return new Promise(async resolve => {
        // 此处相当于请求了接口
        this.menus = await getMenus()
        collectPermissionCodes(this.menus)
        resolve(this.menus)
      })
    },
  },
});